import { EyeOutlined } from "@ant-design/icons"
import { useRequest } from "@umijs/max"
import { Image } from 'antd'
import { request } from '@umijs/max';

export async function getTempUrl(
    params: {
      [key: string]: any
    },
    options?: { [key: string]: any },
  ) {
    return request<{
      code: number;
      msg?: string;
      data?: any
    }>('/engine-service/api/v1/file/get_temp_url', {
      params,
      ...(options || {}),
    });
  }

const ImagePreview = ({ imgUrl }: any) => {

    const { data } = useRequest(() => getTempUrl({ fileUrl: imgUrl }), {
        ready: !!imgUrl
    })

    return data ? <Image width={50} preview={{
        mask: <EyeOutlined />
    }} src={data} /> : '-'
}

export default ImagePreview